import 'command_item.dart';
import 'command_manager.dart';
import 'back_event.dart';

class Sightable extends Object with CommandItem, CommandManager {
  String id = '';
  String code = '';
  String name = '';
  Sightable preview;
  Sightable(String name){
    this.name = name;
  }

  void copyData(dynamic obj) {
    this.id = obj.id;
    this.code = obj.code;
    this.name = obj.name;
  }

  void setPreview(Sightable preview){
    this.preview = preview;
    if (preview != null) {
      // print(this.name + ' setPreview ' + preview?.name ?? 'null');
      this.add(BackEvent());
    } else {
      this.commands.removeWhere((item) => item is BackEvent);
    }
  }
}